// 获取用户信息
function getUserInfo() {
    $.ajax({
        url: '/my/user/userinfo',
        // 请求头中携带token

        success: function(res) {
            // console.log(res);
            if (res.status === 0) {
                let name = res.data.nichname || res.data.username
                $('.username').text(name)
                if (res.data.user_pic) {
                    $('.layui-nav-img').attr('src', res.data.user_pic).show()
                } else {
                    let first = res.data.username.substring(0, 1).toUpperCase()
                    $('.text-avatar').text(first).css('display', 'inline-block')
                }
            }
        }

    });
}
getUserInfo()



//退出功能
$('#logout').on('click', function() {
    layer.confirm('确定退出吗?', function(index) {
        //点击确定.移除token
        localStorage.removeItem('token')
            //跳转页面
        location.href = './login.html'
            // 调用   layer.close(index),关闭弹层
        layer.close(index)
    })
})